<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>文本咨询</title>
    <style type="text/css">
       #textarea{
            border: 0px;
            width: 500px;
            height: 500px;
        }
        /*.read{*/
        /*    border: 0px;*/
        /*    width: 1280px;*/
        /*    height: 720px;*/
        /*    margin: 0px auto;*/
        /*    background: url("../img/bg2.jpg");*/
        /*    color: white;*/
        /*}*/
        /*.textarea{*/
        /*    color: white;*/
        /*   */
        /*    overflow-y:visible*/

        /*}*/
    </style>
</head>
<body >

    <div >
        <div style="border: 0px solid white; width: 500px; height: 100px;margin: 0 auto;">
            <h1>
                <P th:text="${rotation.title}"></P>
            </h1>
        </div>

        <div style="border: 0px solid #000000; width: 500px; height: 100%;margin: 0 auto;background: black">
            <textarea  readonly="readonly" class="textarea" style="resize:none;" th:id="textarea" th:text="${rotation.content}"></textarea>
        </div>
    </div>
    <!-- 评论-->
    <div  style="border: 0px solid white; width: 500px; height: 100px;margin: 0 auto;">
        <div>
            <textarea id="comment" placeholder="发个评论吧!" class="textarea" style="width: 500px ;height: 70px;resize: none;" ></textarea>
            <br>
            <button onclick="submitComment()" th:onclick="'submitComment('+${rotation.id}+')'">发送</button>
        </div>
        <div>
            <div th:each="com:${comList}">
                <div><p th:text="${com.name}"></p><p th:text="${com.cotime}"></p></div>
                <div><p th:text="${com.content}"></p></div>
            </div>
        </div>
    </div>

</body>
</html>
<script type="text/javascript" src="/js/1.8.2.min.js"></script>
<script type="text/javascript">
    function submitComment(id) {
        var  usedata = {};
        var v = "[[${session.userName}]]";
        usedata['name']= v ;

        usedata['rotationid']= id;
        usedata['content']= $("#comment").val();
        // 使用AJAX提交数据
        $.ajax({
            type: "POST",
            contentType: "application/json",
            url: "/comment",
            data: JSON.stringify(usedata) ,
            success: function (data) {
                $("#comment").val("");
            }
        });
    }
</script>